//
//  Tools.m
//  ios-test
//
//  Created by Apple -11 on 15/10/10.
//  Copyright (c) 2015年 Apple -11. All rights reserved.
//

#import "Tools.h"

@implementation Tools


//判断手机号
+(BOOL)CheckInput1:(NSString *)text{
    
    NSString *Regex=@"^1[34578]\\d{9}$";
    NSPredicate *emailTest=[NSPredicate predicateWithFormat:@"SELF MATCHES%@",Regex];
    return [emailTest evaluateWithObject:text];
}
//判断邮箱
+(BOOL)CheckInput2:(NSString *)text{
    NSString *Regex=@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest=[NSPredicate predicateWithFormat:@"SELF MATCHES%@",Regex];
    return [emailTest evaluateWithObject:text];
}

+(BOOL)CheckInput3:(NSString *)text{
    //NSString *Regex=@"(?=^.{6,}$)(?=.*\d)(?=.*\W+)(?=.*[A-Z])(?=.*[a-z])(?!=.*\n).*$";
//    NSString *Regex=@"^[A-Za-z0-9]\\{6,12}$";
//    NSPredicate *emailTest=[NSPredicate predicateWithFormat:@"SELF MATCHES%@",Regex];
//    return [emailTest evaluateWithObject:text];
    NSScanner *scan=[NSScanner scannerWithString:text];
    int val;
    return [scan scanInt:&val] && [scan isAtEnd];

}

+(BOOL)CheckInput4:(NSString *)text{
    
    NSString *Regex=@"^\\d{4}$";
    NSPredicate *emailTest=[NSPredicate predicateWithFormat:@"SELF MATCHES%@",Regex];
    return [emailTest evaluateWithObject:text];
}
@end
